evtchn/fifo: only set READY for new heads
authorDavid Vrabel <david.vrabel@citrix.com>
Mon, 25 Nov 2013 10:15:05 +0000 (11:15 +0100)
committerJan Beulich <jbeulich@suse.com>
Mon, 25 Nov 2013 10:15:05 +0000 (11:15 +0100)
commit70ccddb14a99ada447602ca01250a1183363bc49
tree50d2f4bd56ea6a934652959e1add33725b80356a
parent9bc72c626512d7d79a7f0295fbfa7cd597ce620a
evtchn/fifo: only set READY for new heads

Setting a queue's READY bit for every event added to the queue
introduces a race.

If an event is added to the tail of a queue, the guest may consume the
newly added event and leave an empty queue before the READY is set.
The guest may then see a stale HEAD value and if the event at the
stale head became linked onto a different queue, the guest would
consume events from the wrong queue (corrupting it).

As noted in section 4.1.2 of the design document, only set READY if a
new HEAD is set.  This ensures that if the guest sees a READY bit set
the corresponding HEAD is valid.

Signed-off-by: David Vrabel <david.vrabel@citrix.com>
xen/common/event_fifo.c